package router

import (
	"github.com/gin-gonic/gin"
	"morleyStoneHome/controller"
	"net/http"
	"time"
)

func ConfigRouter(router *gin.Engine) {
	newsController := controller.NewNewsController()
	captchaController := controller.NewIdController()
	catcoinController := controller.NewCatcoinController()
	stoController := controller.NewStoController()
	router.POST("/home/newsList", newsController.NewsList)
	router.POST("/home/news/:newsId", newsController.News)
	router.GET("/home/capt/getone", captchaController.GetOne)
	router.POST("/home/capt/verify", captchaController.Verify)
	router.POST("/home/catcoin/airdrop/:invcode", catcoinController.Airdrop)
	router.POST("/home/catcoin/airdrop", catcoinController.Airdrop)
	router.GET("/home/catcoin", catcoinController.GetOne)
	router.POST("/home/getsign", stoController.SignData)
	router.POST("/home/freeze", stoController.Freeze)
	router.POST("/home/getfollowers", catcoinController.GetFollowers)
	router.StaticFS("/static", http.Dir("D:\\goDevelop\\WORKSPACE_A\\morleyhome\\static"))
}

func ConfigGin(port string, routerDefault *gin.Engine) *http.Server {
	webServer := &http.Server{
		Addr:           port,
		Handler:        routerDefault,
		ReadTimeout:    15 * time.Second,
		WriteTimeout:   15 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	return webServer
}
